package com.ece.core.editors.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jdt.internal.ui.commands.OpenElementInEditorHandler;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;

/**
 * suppsed to handle opening of the editor in the in the Java perspective.
 * 
 * @see org.eclipse.core.commands.IHandler
 * @see org.eclipse.core.commands.AbstractHandler
 */
public class OpenJavaEditorHandler extends AbstractHandler {

    private final AbstractHandler nativeHandler;

    /**
     * The constructor.
     */
    public OpenJavaEditorHandler() {
	nativeHandler = new OpenElementInEditorHandler();
    }

    /**
     * the command has been executed, so extract extract the needed information
     * from the application context.
     */
    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
	nativeHandler.execute(event);
	IWorkbenchWindow window = HandlerUtil
		.getActiveWorkbenchWindowChecked(event);
	MessageDialog.openInformation(window.getShell(), "Review",
		"Hello, Eclipse world");
	System.out.println("[INFO] Hello Aloha from Open Editor Handler");
	return null;
    }
}
